namespace Bowlus.FrontEnd.RequestRouting.ApplicationDeployment
{

    using Bowlus.Common;
    using Bowlus.Common.DeploymentActions;

    public class DeleteApplicationRequest : ApplicationDeploymentRequest
    {
        public DeleteApplicationRequest(TenantDeployment tenantDeployment, ApplicationHost applicationHost)
            : base(tenantDeployment)
        {
            this.FromHost = applicationHost;
        }

        public ApplicationHost FromHost { get; private set; }

        protected override string RequestType
        {
            get
            {
                return DeploymentActionType.DeleteFromAppHost;
            }
        }

        public override void MakeDeploymentRequest()
        {
            this.TenantDeployment.Status = TenantDeploymentStatus.DeployRequestSubmitted;
            this.TenantDeployment.DeploymentAction = this.RequestType;
            this.TenantDeployment.AppHostInstanceId = this.FromHost.InstanceId;
            this.TenantDeployment.AppHostInstanceIp = this.FromHost.ApphostHttpEndpoint.Address.ToString();

            TenantDeploymentsStore.UpdateDeploymentStore(this.TenantDeployment);
        }
    }
}